<template>
  <div>
    首页

    <button @click="$router.push('/dashboard?t=' + Date.now())">
      跳转路由
    </button>
  </div>
</template>
<script>
export default {
  data() {
    return {
      str: '我是首页'
    }
  },
  created() {
    console.log('我是首页created')
  },
  beforeRouteEnter(to, from, next) {
    console.log('beforeRouteEnter', this)
    next((vm) => {
      console.log(vm.str)
    })
  },
  // 路由变化了，但路由所对应组件不变
  beforeRouteUpdate(to, from, next) {
    console.log('beforeRouteUpdate', to.query.t)
    next()
  },
  beforeRouteLeave(to, from, next) {
    console.log('beforeRouteLeave')
    next()
  }
}
</script>
<style></style>
